<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/base/base.jsp"%>
<%@ include file="/base/database.jsp" %>
	
	<%
		request.setCharacterEncoding("utf-8");
	
		String courseID=request.getParameter("courseID");
		String classID=request.getParameter("classID");
		String courseName=request.getParameter("courseName");
		String year=request.getParameter("year");
		String term=request.getParameter("term");
		String hour=request.getParameter("hour");
		
		StringBuffer sqlBuff=new StringBuffer();
		sqlBuff.append("insert into sys_course(courseID,classID,courseName,year,term,hour)");
		sqlBuff.append("value(?,?,?,?,?,?,?,?)");
		String sql=sqlBuff.toString();
		
		String url="jdbc:mysql://localhost:3306/leave";
		String user="root";
		String password="";
		Class.forName("com.mysql.jdbc.Driver");
		Connection conn=DriverManager.getConnection(url,user,password);
		PreparedStatement pstmt=conn.prepareStatement(sql);
		
		int parameterIndex=1;
		pstmt.setString(parameterIndex++,courseID);
		pstmt.setString(parameterIndex++,classID);
		pstmt.setString(parameterIndex++,courseName);
		pstmt.setString(parameterIndex++,year);
		pstmt.setString(parameterIndex++,term);
		pstmt.setString(parameterIndex++,hour);
		
		int c=pstmt.executeUpdate();
		
		if(pstmt!=null){
			pstmt.close();
		}
		if(conn!=null){
			conn.close();
		}
		
		process(request,response,"/page/instructor/course_list.jsp");
		
	%>